from datetime import datetime

from pydantic import BaseModel, Field

from enums.crawler_enum import ProjectType, CrawlerType, DateRangeType, RoomUseType, RoomState


class CrawlerJiNanArgs(BaseModel):
    project_type: ProjectType = Field(default=ProjectType.ALL, description="项目类型")
    project_county: str = Field(default="", description="项目所在区县")
    project_name: str = Field(default="", description="项目名称")

class CrawlerLandArgs(BaseModel):
    year: int = Field(default=datetime.now().year, min=2000, max=datetime.now().year)
    month: int = Field(default=datetime.now().month, min=1, max=12)
    day: int = Field(default=datetime.now().day, min=1, max=31)
    crawler_type: CrawlerType
    crawler_url: str = Field(default="https://www.wanshudata.com/dataQuery/3556")
    city: str = Field(default="济南")
    date_range_type: DateRangeType = Field(default=DateRangeType.MONTHLY)
    transaction_status_condition: list[RoomUseType] = Field(default_factory=lambda: [RoomUseType.HOUSE], min_length=1)
    sale_method_condition: list[RoomState] = Field(default_factory=lambda x: [RoomState.ALL], max_length=1)

class CrawlerHeFeiArgs(BaseModel):
    county: str = Field(default='')
    house_type: str = Field(default="住宅")

class CrawlerCommunityByName(BaseModel):
    community_name: str = Field(default='小区名称')
    province: str = Field(default='省份')
    area: str = Field(default='城市')
    county: str = Field(default='区县')